//
//  UIImageView+ImageCorner.m
//  cnwan
//
//  Created by LY-Coder on 2017/10/13.
//  Copyright © 2017年 xchuang. All rights reserved.
//

#import "UIImageView+ImageCorner.h"

@implementation UIImageView (ImageCorner)
+(UIImageView *)drawImageRectWithRect:(CGRect)frame byImageName:(NSString *)imag{
    
    UIImageView *imageView=[[UIImageView alloc]initWithFrame:frame];
    
    imageView.image=[UIImage imageNamed:imag];
    
    UIBezierPath *maskPath=[UIBezierPath bezierPathWithRoundedRect:imageView.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:imageView.bounds.size];
    
    CAShapeLayer *maskLayer=[[CAShapeLayer alloc]init];
    
    //设置大小
    maskLayer.frame=imageView.bounds;
    
    //设置图形样子
    maskLayer.path=maskPath.CGPath;

    imageView.layer.mask=maskLayer;

    return imageView;
}
@end
